<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('查询本单位电话工单')"/>
    <link rel="stylesheet" type="text/css" th:href="@{/ajax/libs/qxEasyUI/themes/default/easyui.css}">
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="workFormNO"/>
                        </li>
                        <li>
                            工单主题：<input type="text" name="fromTopic"/>
                        </li>
                        <li>
                            流水号：<input type="text" name="wsCode"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>
                        <li>
                            内容类别：
                            <span class="combo" style="width: 197px; height: 31px;">
                                <input type="text"  autocomplete="off" >
                            </span>
                        </li>
                        <li class="select-time" style="margin: 5px 5px 5px -1px">
                            <label>创建时间： </label>
                            <input type="text" class="time-input mr10" id="startTime" placeholder="开始时间" autocomplete="off" readonly="readonly"
                                   name="beginTime"/>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" autocomplete="off" readonly="readonly"
                                   name="endTime"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                            <!--<button type="button" class="btn btn-primary btn-sm" data-toggle="modal"
                                    data-backdrop="static" data-target="#myModal">
                                <i class="glyphicon glyphicon-zoom-out bt-search"></i>&nbsp;高级查询
                            </button>-->
                        </li>
                    </ul>
                </div>
            </form>
            <form id="form-user-add">
                <div class="modal inmodal" id="myModal" role="dialog" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content animated bounceInRight">
                            <!--                            <button type="button" class="close" data-dismiss="modal"><span-->
                            <!--                                    aria-hidden="true">X</span><span class="sr-only">关闭</span>-->
                            <!--                            </button>-->
                            <div class="modal-body">
                                <div>
                                    <a href="javascript:void(0);" onclick="snrFindCdtnShow()">查看条件</a>
                                    <a href="javascript:void(0);" onclick="snrCdtnClear()">清空条件</a>
                                </div>
                                <div id="dlg_Setbar" style="margin-bottom:10px;">
                                    <span class="spLBlue">点击这里增加条件设置：</span>
                                    <a href="javascript:void(0);" class="btn btn-primary glyphicon glyphicon-plus"
                                       role="button"
                                       title="增加条件" onClick="snrAddCd(cdtnsSnr);"></a>
                                </div>
                                <div id="cdtnCell">
                                    <table id="tabSnrCdtn" cellspacing="1" cellpadding="1" width="98%"
                                           border="0">
                                        <tr>
                                            <td><select name="cdnField" class="form-control formSelect"
                                                        style="width: 100px">
                                                <option value="WsCode">流水号</option>
                                                <option value="WorkFormNO">工单编号</option>
                                                <option value="SetProName">工单性质</option>
                                                <option value="FromTel">来电号码</option>
                                                <option value="FromName">来电人名</option>
                                                <option value="FmAreaName">所属地区</option>
                                                <option value="IptWorker">派单人</option>
                                                <option value="fromTopic">主题</option>
                                                <option value="fmContent">信件内容</option>
                                            </select></td>
                                            <td><select name="cdnOper" class="form-control formSelect"
                                                        style="width: 90px">
                                                <option value="201">包含</option>
                                                <option value="101">等于</option>
                                                <option value="202">不包括</option>
                                                <option value="102">不等于</option>
                                                <option value="120">大于</option>
                                                <option value="110">小于</option>
                                            </select></td>
                                            <td align="left"><input name="cdnKey" class="form-control"
                                                                    type="text" maxlength="30"></td>
                                            <td><a href="javascript:void(0);"
                                                   class="btn btn-danger glyphicon glyphicon-minus"
                                                   role="button" title="移除此条件"
                                                   onclick="snrRemoveCdtn(this)" alt="移除此条件"></a></td>
                                            <td><select name="cdnCnt" class="form-control formSelect"
                                                        style="width: 80px">
                                                <option value="and">并且</option>
                                                <option value="or">或者</option>
                                            </select></td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-primary" onclick="submitHandler()">确定</button>
                                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-info" onclick="exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
            <a class="btn btn-info" onclick="exTelExcel()">
                <i class="fa fa-download"></i> 不满意件导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" class="table-striped"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/ajax/libs/qxEasyUI/jquery.easyui.min.js}"></script>
<script th:src="@{/common/js/hm-ui.js?a=100}"></script>
<script th:inline="javascript">

    var prefix = ctx + "system/lookup";

    $(function () {
        var options = {
            url: prefix + "/telWFDeptListJson",
            detailUrl: "/system/lookup/telOrderDetail/{id}",
            exportUrl: prefix + "/telWFDept/export",
            sortName: "pkId",
            sortOrder: "desc",
            uniqueId: "pkId",
            modalName: "本单位电话工单（最近6个月）",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 2,
            columns: [{
                checkbox: true
            },
                {field:'WorkFormNO',title:'工单编号',align:'left',halign:'center',sortable:true},
                {field:'FromTopic',title:'工单主题',align:'left',halign:'center'},
                {field:'FmContent',title:'工单内容',align:'left',
                    formatter:function (value, row, index,field) {
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field:'SpareString',title:'来源',align:'left',halign:'center',sortable:true},
                {field:'SeqName',title:'交办次序',align:'center'},
                {field:'BackLimit',title:'办理期限',align:'center',sortable:true},
                {field:'BackTime',title:'回复日期',align:'center'},
                {field:'BackState',title:'审查情况',align:'center',formatter:function(value,row,index){return fmtSBBackCheck(value,row,index);}},
                {field:'BackRemark',title:'备注',align:'left',halign:'center',
                    formatter:function (value, row, index,field) {
                        if (value==undefined){
                            value='';
                        }
                        return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field:'JudgeC',title:'满意度',align:'center',sortable:true,
                    formatter(value){
                        if(value == '1'){
                            return '不满意';
                        }else if(value == '4'){
                            return '基本满意';
                        }else if(value == '5'){
                            return '满意';
                        }else {
                            return '';
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-outline btn-xs " href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.WfId + '\')">查看</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    var cdtnsSnr = [{
        field: 'WsCode',
        showText: '流水号'
    }, {
        field: 'WorkFormNO',
        showText: '工单编号'
    }, {
        field: 'SetProName',
        showText: '工单性质'
    }, {
        field: 'FromTel',
        showText: '来电号码'
    }, {
        field: 'FromName',
        showText: '来电人名'
    }, {
        field: 'FmAreaName',
        showText: '所属地区'
    }, {
        field: 'IptWorker',
        showText: '派单人'
    }, {
        field: 'fromTopic',
        showText: '主题'
    }, {
        field: 'fmContent',
        showText: '信件内容'
    }];

    function snrAddCd(fpJson) {
        var tabObj = document.getElementById("tabSnrCdtn");
        var tRs = tabObj.rows.length;
        var nwRw = tabObj.insertRow(tRs);
        var clA = nwRw.insertCell(0);
        var clB = nwRw.insertCell(1);
        var clC = nwRw.insertCell(2);
        var clD = nwRw.insertCell(3);
        var clE = nwRw.insertCell(4);

        var fldNames = ""; //fldPro(1=string,2=number,3=datetime)
        $.each(fpJson, function (i, n) {
            fldNames += '<option value="' + n.field + '">' + n.showText + '</option>';
        });
        clA.innerHTML = "<select name=\"cdnField\" class=\"form-control formSelect\" style=\"width: 100px\">" + fldNames + "</select>";
        // clA.height = "28";

        var opStr = '<select name="cdnOper"  class="form-control formSelect" style="width: 90px"><option value="201">包含</option><option value="101">等于</option><option value="202">不包括</option><option value="102">不等于</option><option value="120">大于</option><option value="110">小于</option></select>';
        clB.innerHTML = opStr;

        var cntDdl = '<select name="cdnCnt" class="form-control formSelect" style="width: 80px"><option value="and">并且</option><option value="or">或者</option></select>';
        clE.innerHTML = cntDdl;

        var keyIpt = '<input name="cdnKey" class="form-control" type="text" maxlength="30"  />';
        clC.innerHTML = keyIpt;
        clC.align = "left";

        var rmvBtn = '<a href="javascript:void(0);" class="btn btn-danger glyphicon glyphicon-minus" role="button"  title="移除此条件" onClick="snrRemoveCdtn(this)" alt="移除此条件" />';
        clD.innerHTML = rmvBtn;
    }

    function snrRemoveCdtn(e) {
        var rIdx = e.parentNode.parentNode.rowIndex;
        //alert(rIdx);
        document.getElementById("tabSnrCdtn").deleteRow(rIdx);
    }

    //    关闭
    function gclose() {
        $.modal.close();
    }

    var prefix = ctx + "system/lookup";

    function submitHandler() {
        var tabObj = document.getElementById("tabSnrCdtn");
        var tRs = tabObj.rows.length;
        var showStr = 'goto Search';
        var canSch = false;
        if (tRs < 1) {
            showStr = '<span class="f14 spLRed">您没有设置任何条件！</span>';
            $.modal.alert(showStr);
            return false;
        } else {
            showStr = '<span class="f14 spLRed">您没有设置有效的查询条件！</span>';
            for (var i = 0; i < tRs; i++) {
                var objCnt = tabObj.rows[i].cells[2].childNodes[0];
                var tmpKey = objCnt.value.trim();
                if (tmpKey.length > 0) {
                    canSch = true;
                }
            }
        }
        if (!canSch) {
            $.modal.alert(showStr)
        } else {
            $.table.search('form-user-add')
        }
    }

    function snrCdtnClear() {
        var tabObj = document.getElementById("tabSnrCdtn");
        var tRs = tabObj.rows.length;
        for (var i = 0; i < tRs - 1; i++) {
            tabObj.deleteRow(0);
            let objKey = tabObj.rows[0].cells[2].childNodes[0];
            objKey.value = "";
        }
    }

    function snrFindCdtnShow() {
        var tabObj = document.getElementById("tabSnrCdtn");
        var tRs = tabObj.rows.length;
        var showStr = 'the condition';
        if (tRs < 1) {
            showStr = '<span class="f14 spLRed">系统提示：您没有设置任何条件！</span>';
            $.modal.alert(showStr);
        } else {
            showStr = "";
            for (var i = 0; i < tRs; i++) {
                var objFld = tabObj.rows[i].cells[0].childNodes[0];
                var objOP = tabObj.rows[i].cells[1].childNodes[0];
                var objKey = tabObj.rows[i].cells[2].childNodes[0];
                var objCnt = tabObj.rows[i].cells[4].childNodes[0];
                showStr += objFld.options[objFld.selectedIndex].text + " <span class='spRed'>" + objOP.options[objOP.selectedIndex].text + "</span> <span class='spLBlue'>" + objKey.value + "</span> <span class='spOrange'>" + objCnt.options[objCnt.selectedIndex].text + "</span><br/><br/>";
            }
            $.modal.alert(showStr);
        }
    }

    // 选择内容分类
    // $('#qxCT').combotree({
    //     url: '/system/common/findContentCate',
    //     required: false,
    //     onSelect: function (record) {
    //         $("#txtDcntAcode").val(record.id);
    //     }
    // });
    // $('#qxCT').css({"clear":"both"});

    function reset() {
        $("#txtDcntAcode").val('');
        $.form.reset();
    }

    //导出不满意件、下级单位导出
    function exTelExcel(){
        let exURL =  prefix + "/UnsatisfyTelWF/export";
        let data = $("#post-form").serializeArray();
        let reminder = "确定导出（最近6个月）本单位不满意信件工单吗？"
        let startTime = $('#startTime').val();
        let endTime = $('#endTime').val();
        if(startTime !== "" || endTime !== ""){
            reminder = "确定导出本单位不满意信件工单吗？"
        }
        $.modal.confirm(reminder, function() {
            $.modal.loading("正在导出数据，请稍候...");
            $.post(exURL,data,function(result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }

    function exportExcel(){
        let startTime = $('#startTime').val();
        let endTime = $('#endTime').val();
        if(startTime !== "" || endTime !== ""){
            table.options.modalName = "本单位电话工单"
        }
        $.table.exportExcel()
    }

</script>
</body>
</html>